/**
 * 
 */
package hb_Teach_InitObject_Equals;

/**
 * @author Jiang Zhiyan
 *
 * 2021年4月30日 上午8:59:45
 */
public class User {
   private String id;
   private String username;
   private String pwd;
   private int level;
   
//   定义输入的对象是否与所设的id、username、level、一致
   @Override
   public boolean equals(Object obj) {
	   //是否为空
	   if(obj==null) {
		   return false;
	   }
	   //是否为同一对象
	   if(this==obj) {
		   return true;
	   }
	   //（是否为同一的类型） 如果obj运行时类型为User类才具备可比性
	   if(obj instanceof User) {
		   //1.obj类类型强转成User类型
		   User user = (User) obj;
		   //2.分别比较属性
		   return this.id.equals(user.id)&&this.username.equals(user.username)&&this.level==user.level;
	   }
	   return false;
   }
   /**
    * 快捷键：alt+s 点击toString 的那一个
    */
   @Override
public String toString() {
	return "User [id=" + id + ", username=" + username + ", pwd=" + pwd + ", level=" + level + "]";
}

   //构造器初始化
public User() {
	 super();
 }
/**
 * 快捷键：alt+s using fields
 * @param id
 * @param username
 * @param pwd
 * @param level
 */
public User(String id, String username, String pwd, int level) {
	super();
	this.id = id;
	this.username = username;
	this.pwd = pwd;
	this.level = level;
}
/**
 * @return the id
 */
public String getId() {
	return id;
}
/**
 * @param id the id to set
 */
public void setId(String id) {
	this.id = id;
}
/**
 * @return the username
 */
public String getUsername() {
	return username;
}
/**
 * @param username the username to set
 */
public void setUsername(String username) {
	this.username = username;
}
/**
 * @return the pwd
 */
public String getPwd() {
	return pwd;
}
/**
 * @param pwd the pwd to set
 */
public void setPwd(String pwd) {
	this.pwd = pwd;
}
/**
 * @return the level
 */
public int getLevel() {
	return level;
}
/**
 * @param level the level to set
 */
public void setLevel(int level) {
	this.level = level;
}
}
